package com.qk.mapper;

import com.qk.dto.CourseDto;
import com.qk.entity.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseMapper {


    List<Course> list(CourseDto courseDto);

    /**
     *delete course by id
     */
    @Delete("delete from course where id=#{id}")
    void delete(Integer id);

    /**
     *  add course
     */
    @Insert("insert into course(subject,name,price,target,description,create_time,update_time) values(#{subject},#{name},#{price},#{target},#{description},#{createTime},#{updateTime})")
    void insert(Course course);

    /**
     *select course by id
     */
    @Select("select id, subject, name, price, target, description, create_time, update_time from course where id= #{id}")
    Course getById(Integer id);

    /**
     * update course
     */
    @Update("update course set subject=#{subject}, name=#{name}, price=#{price}, target=#{target}, description=#{description}, update_time=#{updateTime} where id=#{id}")
    void update(Course course);
    /**
     * list all course
     */
    @Select("select id, subject, name, price, target, description, create_time, update_time from course")
    List<Course> listAll();

    /**
     *select all course by subject
     */
    @Select("select id, subject, name, price, target, description, create_time, update_time from course where subject= #{subject}")
    List<Course> listBySubject(Integer subject);


}
